<template>
	<view class="container">
		<view class="textBox">
			<view class="t1">是什么事情</view>
			<view class="t1">让你感受到{{myMood}}呐</view>
		</view>
		<view class="choiceBox">
			<view class="row" v-for="(things, rowIndex) in thingGroups" :key="rowIndex">
			    <view
			        v-for="(thing, colIndex) in things"
			        :key="colIndex"
			        class="choice"
			        :style="{ backgroundColor: thingMap[thing] === selectedThing ? 'white' : 'unset' }"
			        @click="selectMood(thing)">
					<image style="width: 80rpx; height: 80rpx;" :src="thingMap[thing]"></image>
			        <text>{{thing}}</text>
				</view>
			</view>
		</view>
		<button class="btn" @click="toText">那我开始讲了</button>
		<button class="btn1" @click="toExit">下次再讲,保存退出</button>
	</view>
</template>

<script setup lang="ts">
	import {ref} from 'vue'
	import {onLoad} from '@dcloudio/uni-app'
	const thingList = ref([
		'../../static/thing1.svg',
		'../../static/thing2.svg',
		'../../static/thing3.svg',
		'../../static/thing4.svg',
		'../../static/thing5.svg',
		'../../static/thing6.svg',
		'../../static/thing7.svg',
		'../../static/thing8.svg',
		'../../static/thing9.svg'
	])
	const thingGroups = ref([
	        ['学习', '旅行', '音乐'],
	        ['游戏', '聚会', '工作'],
	        ['家庭', '食物', '休息']
	      ])
	const thingMap = {
		'学习': thingList.value[0],
		'旅行': thingList.value[1],
		'音乐': thingList.value[2],
		'游戏': thingList.value[3],
		'聚会': thingList.value[4],
		'工作': thingList.value[5],
		'家庭': thingList.value[6],
		'食物': thingList.value[7],
		'休息': thingList.value[8]
	};
	 
	const selectedThing = ref(thingList.value[0]); // 初始选中第一个图片
	const myMood = ref('');
	onLoad((option)=>{
		myMood.value = option.mood;
	})
	const selectMood = (thing: string) => {
		selectedThing.value = thingMap[thing]
	};
	const toExit = () =>{
		uni.switchTab({
			url:"/pages/main/main"
		})
	}
	const toText = () =>{
		uni.navigateTo({
			url:"/pages/home/home"
		})
	}
	
</script>

<style lang="scss" scoped>
	.container{
		background-color:#fff2bd;
		width: 100vw;
		height: 100vh;
		display: flex;
		flex-direction: column;
		.textBox{
			margin-top: 150rpx;
			.t1{
				font-size: 32rpx;
				// color: #85784b;
				font-style: italic;
				margin-left: 50rpx;
			}
		}
		
		.choiceBox{
			margin-top: 100rpx;
			.row{
				display: flex;
				justify-content: space-around;
				margin-bottom:20rpx;
				.choice{
					display: flex;
					justify-content: center;
					align-items: center;
					// background-color: white;
					width: 200rpx;
					border-radius: 10rpx;
					height: 100rpx;
					border: #fff 2px solid;
					font-size: 25rpx;
					color: #85784b;
				}
				image{
					height: 60rpx !important;
					width: 60rpx !important;
					margin-right: 20rpx;
				}
			}
		}
		.btn{
			background-color: #fcde63;
			border-radius: 30rpx;
			width: 400rpx;
			color: white;
			font-weight: 700;
			margin-top: 200rpx;
		}
		.btn1{
			background-color: #fff2bd;
			border-radius: 30rpx;
			width: 400rpx;
			color: #85784b;
			font-size: 25rpx;
			margin-top: 20rpx;
			border: unset !important;
			:deep(.uni-button:after){
				border: unset !important;
			}
		}
		
	}          
</style>
